#时间包用来做等待
from time import sleep
#网站驱动
from selenium import webdriver
#导入服务
from selenium.webdriver.chrome.service import Service
#导入一个定位元素工具by
from selenium.webdriver.common.by import By

#准备百度的网址
url = "https://www.baidu.com/"
#实例化服务
service = Service(executable_path='./chromedriver.exe')
#实例化驱动 前面sercive是参数，后面是变量名
driver = webdriver.Chrome(service=service)

# a = ["西瓜","草莓","猕猴桃"]
driver.get(url)
# 自动全屏显示 最大化
driver.maximize_window()
sleep(2)
# for i in a:
#     # 自动化
#     driver.get(url)
#     # 自动全屏显示 最大化
#     driver.maximize_window()
#     sleep(2)
    #通过id是kw 找到百度的输入框，赋值给一个变量ele
    # ele = driver.find_element(By.ID,"kw")
    #通过name=wd 查找
    # ele = driver.find_element(By.NAME,"wd")
    # ele.send_keys(i)
    # sleep(2)
    #点击
    # ele2 = driver.find_element(By.ID,"su")
    # ele2.click()
    # sleep(2)
    #时间间隔长一些

# ele = driver.find_element(By.PARTIAL_LINK_TEXT,"地图")
# ele.click()
# sleep(5)

# ele = driver.find_element(By.LINK_TEXT,"更多")

#tag_name 不建议使用
# ele = driver.find_element(By.TAG_NAME,"input")
# print(ele,type(ele),len(ele))

#class_name定位
ele = driver.find_element(By.CLASS_NAME,"s_pt")
ele.send_keys("熊猫")
ele2 = driver.find_element(By.ID,"su")
ele.click()
sleep(5)

#可以不写 quit
driver.quit()